package com.ruoyi.mall.service.impl;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mall.mapper.MallTimeWithdrawMapper;
import com.ruoyi.mall.domain.MallTimeWithdraw;
import com.ruoyi.mall.service.IMallTimeWithdrawService;

/**
 * 返佣提现Service业务层处理
 *
 * @author ruoyi
 * @date 2022-03-03
 */
@Service
public class MallTimeWithdrawServiceImpl implements IMallTimeWithdrawService
{
    @Autowired
    private MallTimeWithdrawMapper mallTimeWithdrawMapper;

    /**
     * 查询返佣提现
     *
     * @param id 返佣提现主键
     * @return 返佣提现
     */
    @Override
    public MallTimeWithdraw selectMallTimeWithdrawById(Long id)
    {
        return mallTimeWithdrawMapper.selectMallTimeWithdrawById(id);
    }

    /**
     * 查询返佣提现列表
     *
     * @param mallTimeWithdraw 返佣提现
     * @return 返佣提现
     */
    @Override
    public List<MallTimeWithdraw> selectMallTimeWithdrawList(MallTimeWithdraw mallTimeWithdraw)
    {
        return mallTimeWithdrawMapper.selectMallTimeWithdrawList(mallTimeWithdraw);
    }

    /**
     * 新增返佣提现
     *
     * @param mallTimeWithdraw 返佣提现
     * @return 结果
     */
    @Override
    public int insertMallTimeWithdraw(MallTimeWithdraw mallTimeWithdraw)
    {
        mallTimeWithdraw.setCreateTime(DateUtils.getNowDate());
        return mallTimeWithdrawMapper.insertMallTimeWithdraw(mallTimeWithdraw);
    }

    /**
     * 修改返佣提现
     *
     * @param mallTimeWithdraw 返佣提现
     * @return 结果
     */
    @Override
    public int updateMallTimeWithdraw(MallTimeWithdraw mallTimeWithdraw)
    {
        mallTimeWithdraw.setUpdateTime(DateUtils.getNowDate());
        if (mallTimeWithdraw.getStatus() != 1) {
            if (mallTimeWithdraw.getStatus() == 2) {
                mallTimeWithdraw.setIsArrival(2);
            }
            mallTimeWithdraw.setCheckTime(DateUtils.getNowDate());
        }
        return mallTimeWithdrawMapper.updateMallTimeWithdraw(mallTimeWithdraw);
    }

    /**
     * 批量删除返佣提现
     *
     * @param ids 需要删除的返佣提现主键
     * @return 结果
     */
    @Override
    public int deleteMallTimeWithdrawByIds(Long[] ids)
    {
        return mallTimeWithdrawMapper.deleteMallTimeWithdrawByIds(ids);
    }

    /**
     * 删除返佣提现信息
     *
     * @param id 返佣提现主键
     * @return 结果
     */
    @Override
    public int deleteMallTimeWithdrawById(Long id)
    {
        return mallTimeWithdrawMapper.deleteMallTimeWithdrawById(id);
    }

    @Override
    public BigDecimal selectTimeWithdrawRakeBackByUserId(Long userId) {
        return mallTimeWithdrawMapper.selectTimeWithdrawRakeBackByUserId(userId);
    }

    @Override
    public BigDecimal selectTimeWithdrawCashOutByUserId(Long userId) {
        return mallTimeWithdrawMapper.selectTimeWithdrawCashOutByUserId(userId);
    }

    @Override
    public BigDecimal selectTimeWithdrawTodayGainByUserId(Long userId) {
        return mallTimeWithdrawMapper.selectTimeWithdrawTodayGainByUserId(userId);
    }

    @Override
    public BigDecimal selectTimeWithdrawSevenDaysGainByUserId(Long userId) {
        return mallTimeWithdrawMapper.selectTimeWithdrawSevenDaysGainByUserId(userId);
    }

    @Override
    public List<MallTimeWithdraw> selectMyWithdrawList(Long userId, Integer type) {
        return mallTimeWithdrawMapper.selectMyWithdrawList(userId, type);
    }

    @Override
    public Map<String, Object> queryHistoryLineChartSharePrice(Map<String, Object> map) {
        return mallTimeWithdrawMapper.queryHistoryLineChartSharePrice(map);
    }

}
